﻿using B.S.Data.MES.API.Applications.WorkOrderManagement.Commands;
using B.S.Domain.Ticket;
using B.S.Infratrctrue;
using B.S.Requst;
using MediatR;

namespace B.S.Data.MES.API.Applications.WorkOrderManagement.CommandHandlers
{
    public class UpdateStateCommandHandler : IRequestHandler<UpdateStateCommand, APIRequst<int>>
    {
        private readonly IBaseRepository<WorkOrder> _workorderRepository;
        public UpdateStateCommandHandler(IBaseRepository<WorkOrder> workorderRepository)
        {
            _workorderRepository = workorderRepository;
        }
        public Task<APIRequst<int>> Handle(UpdateStateCommand request, CancellationToken cancellationToken)
        {
            var list=_workorderRepository.GetAll().FirstOrDefault(x=>x.WorkId == request.workId);
            list.States = 8;
            _workorderRepository.Update(list);
            return Task.FromResult(new APIRequst<int>
            {
                Code=RequstCode.成功,
                Msg=RequstCode.成功.ToString()
            });
        }
    }
}
